<?php

use ba\Filesystem;

if (!function_exists('get_controller_list')) {
    function get_controller_list($app = 'admin'): array
    {
        $controllerDir = root_path() . 'app' . DIRECTORY_SEPARATOR . $app . DIRECTORY_SEPARATOR . 'controller' . DIRECTORY_SEPARATOR;
        return Filesystem::getDirFiles($controllerDir);
    }
}
if (!function_exists('updateField')) {
     //通用修改字段方法
     function updateField($field, $value): void
     {
          $id = $this->request->post('id');
          $res = $this->model->where('id', $id)->update([$field => $value]);
          if ($res) {
               $this->success('操作成功');
          } else {
               $this->error('操作失败');

          }
     }
}
